home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / auxdlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  6.2 KB  |  195 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include <windows.h>
  19. #include <vfw.h>
  20.  
  21. #include "resource.h"
  22. #include "auxdlg.h"
  23. #include "oshelper.h"
  24.  
  25. #include "IAmpDecoder.h"
  26.  
  27. extern "C" unsigned long version_num;
  28. extern "C" char version_time[];
  29.  
  30. extern HINSTANCE g_hInst;
  31.  
  32. BOOL APIENTRY ShowTextDlgProc( HWND hDlg, UINT message, UINT wParam, LONG lParam) {
  33.     HRSRC hRSRC;
  34.  
  35.     switch (message)
  36.     {
  37.         case WM_INITDIALOG:
  38.             if (hRSRC = FindResource(NULL, (LPSTR)lParam, "STUFF")) {
  39.                 HGLOBAL hGlobal;
  40.                 if (hGlobal = LoadResource(NULL, hRSRC)) {
  41.                     LPVOID lpData;
  42.  
  43.                     if (lpData = LockResource(hGlobal)) {
  44.                         char *s = (char *)lpData;
  45.                         char *ttl = new char[256];
  46.  
  47.                         while(*s!='\r') ++s;
  48.                         if (ttl) {
  49.                             memcpy(ttl, (char *)lpData, s - (char *)lpData);
  50.                             ttl[s-(char*)lpData]=0;
  51.                             SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)ttl);
  52.                             delete ttl;
  53.                         }
  54.                         s+=2;
  55.                         SendMessage(GetDlgItem(hDlg, IDC_CHANGES), WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), MAKELPARAM(TRUE, 0));
  56.                         SendMessage(GetDlgItem(hDlg, IDC_CHANGES), WM_SETTEXT, 0, (LPARAM)s);
  57.                         FreeResource(hGlobal);
  58.                         return TRUE;
  59.                     }
  60.                     FreeResource(hGlobal);
  61.                 }
  62.             }
  63.             return FALSE;
  64.  
  65.         case WM_COMMAND:
  66.             if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
  67.             {
  68.                 EndDialog(hDlg, TRUE);  
  69.                 return TRUE;
  70.             }
  71.             break;
  72.     }
  73.     return FALSE;
  74. }
  75.  
  76. BOOL APIENTRY WelcomeDlgProc( HWND hDlg, UINT message, UINT wParam, LONG lParam)
  77. {
  78.     switch (message)
  79.     {
  80.         case WM_COMMAND:
  81.             switch(LOWORD(wParam)) {
  82.             case IDOK: case IDCANCEL:
  83.                 EndDialog(hDlg, TRUE);  
  84.                 return TRUE;
  85.             case IDC_HELP2:
  86.                 HelpShowHelp(hDlg);
  87.                 return TRUE;
  88.             }
  89.             break;
  90.     }
  91.     return FALSE;
  92. }
  93.  
  94. void Welcome() {
  95.     DWORD dwSeenIt;
  96.  
  97.     if (!QueryConfigDword(NULL, "SeenWelcome", &dwSeenIt) || !dwSeenIt) {
  98.         DialogBox(g_hInst, MAKEINTRESOURCE(IDD_WELCOME), NULL, WelcomeDlgProc);
  99.  
  100.         SetConfigDword(NULL, "SeenWelcome", 1);
  101.     }
  102. }
  103.  
  104. static const char g_szDivXWarning[]=
  105.     "\"DivX\" codec detected\0"
  106.     "One or more of the \"DivX\" drivers have been detected on your system. These drivers are illegal binary hacks "
  107.     "of legitimate drivers:\r\n"
  108.     "\r\n"
  109.     "* DivX low motion/fast motion: Microsoft MPEG-4 V3 video\r\n"
  110.     "* DivX audio: Microsoft Windows Media Audio\r\n"
  111.     "* \"Radium\" MP3: Fraunhofer-IIS MPEG layer III audio\r\n"
  112.     "\r\n"
  113.     "Hacked drivers are known to cause serious problems, including "
  114.     "crashes and interference with the original drivers. When these drivers are loaded, the author cannot "
  115.     "make any guarantees as to the stability of VirtualDub. Please do not "
  116.     "forward crash dumps involving these drivers, as the author has no control "
  117.     "of the original third-party drivers or the binary hacks applied to them.";
  118.  
  119. static const char g_szAPWarning[]=
  120.     "\"AngelPotion Definitive\" codec detected\0"
  121.     "The \"AngelPotion Definitive\" codec has been detected on your system. This driver is an illegal binary hack "
  122.     "of the following legitimate drivers:\r\n"
  123.     "\r\n"
  124.     "* Microsoft MPEG-4 V3 video\r\n"
  125.     "\r\n"
  126.     "The AngelPotion codec is a particularly poor hack of the MS MPEG-4 V3 codec and is known "
  127.     "to cause a number of serious conflicts, including but not limited to:\r\n"
  128.     "* Excessive disk usage on temporary drive\r\n"
  129.     "* Incorrectly responding to compressed formats of other codecs, even uncompressed RGB\r\n"
  130.     "* Preventing some applications from loading AVI files at all\r\n"
  131.     "* Inhibiting Windows Media Player automatic codec download\r\n"
  132.     "\r\n"
  133.     "The author cannot guarantee the stability of VirtualDub in any way when AngelPotion is loaded, "
  134.     "even if the codec is not in use. All crash dumps indicating AP is loaded will be promptly discarded. "
  135.     "It is HIGHLY suggested that you uninstall AngelPotion immediately."
  136.     ;
  137.  
  138. BOOL APIENTRY DivXWarningDlgProc( HWND hdlg, UINT message, UINT wParam, LONG lParam)
  139. {
  140.     const char *s;
  141.  
  142.     switch (message)
  143.     {
  144.         case WM_INITDIALOG:
  145.             s = (const char *)lParam;
  146.             SetWindowText(hdlg, s);
  147.             while(*s++);
  148.             SendDlgItemMessage(hdlg, IDC_WARNING, WM_SETTEXT, 0, (LPARAM)s);
  149.             return TRUE;
  150.  
  151.         case WM_COMMAND:
  152.             switch(LOWORD(wParam)) {
  153.             case IDOK: case IDCANCEL:
  154.                 EndDialog(hdlg, TRUE);
  155.                 return TRUE;
  156.             }
  157.             break;
  158.     }
  159.     return FALSE;
  160. }
  161.  
  162. static bool DetectDriver(const char *pszName) {
  163.     char szDriverANSI[256];
  164.     ICINFO info;
  165.  
  166.     for(int i=0; ICInfo(ICTYPE_VIDEO, i, &info); ++i) {
  167.         if (WideCharToMultiByte(CP_ACP, 0, info.szDriver, -1, szDriverANSI, sizeof szDriverANSI, NULL, NULL)
  168.             && !stricmp(szDriverANSI, pszName))
  169.  
  170.             return true;
  171.     }
  172.  
  173.     return false;
  174. }
  175.  
  176. void DetectDivX() {
  177.     DWORD dwSeenIt;
  178.  
  179.     if (!QueryConfigDword(NULL, "SeenDivXWarning", &dwSeenIt) || !dwSeenIt) {
  180.         if (DetectDriver("divxc32.dll") || DetectDriver("divxc32f.dll")) {
  181.             DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_DIVX_WARNING), NULL, DivXWarningDlgProc, (LPARAM)g_szDivXWarning);
  182.  
  183.             SetConfigDword(NULL, "SeenDivXWarning", 1);
  184.         }
  185.     }
  186.     if (!QueryConfigDword(NULL, "SeenAngelPotionWarning", &dwSeenIt) || !dwSeenIt) {
  187.         if (DetectDriver("APmpg4v1.dll")) {
  188.  
  189.             DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_DIVX_WARNING), NULL, DivXWarningDlgProc, (LPARAM)g_szAPWarning);
  190.  
  191.             SetConfigDword(NULL, "SeenAngelPotionWarning", 1);
  192.         }
  193.     }
  194. }
  195.